package com.lagou.edu.controller;

import com.lagou.edu.service.MailServiceFeignClient;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author lyj
 * @Title: CodeController
 * @ProjectName homework-parent
 * @Description: TODO
 * @date 2021/1/2 20:33
 */
@RestController
@RequestMapping("/code")
public class CodeController {

    @Autowired
    private MailServiceFeignClient mailServiceFeignClient;
    /**
     * 发送验证码到邮箱
     * @param email
     * @param
     * @return
     */
    @GetMapping("/create/{email}")
    public String create(@PathVariable("email")String email){
        boolean message = mailServiceFeignClient.email(email);
        System.out.println("远程调用邮件服务完成："+message);
        return "验证码已经成功发送到邮箱";

    }

    /**
     * 校验验证码是否正确，0正确1错误2超时
     * @param email
     * @param code
     * @return
     */
    @GetMapping("/validate/{email}/{code}")
    public String validate(@PathVariable("email")String email,
                            @PathVariable("code")String code){

        return "true";

    }

}
